package com.dmzc.stack;

import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

/**
 * 8、用队列实现栈
 */
public class ImplementStackUseQueue {
    public static void main(String[] args) {

    }
}

class MyStack {
    private final LinkedList<Integer> ll;

    /**
     * Initialize your data structure here.
     */
    public MyStack() {
        this.ll = new LinkedList<>();

    }

    /**
     * Push element x onto stack.
     */
    public void push(int x) {
        this.ll.addLast(x);
    }

    /**
     * Removes the element on top of the stack and returns that element.
     */
    public int pop() {
        return this.ll.removeLast();
    }

    /**
     * Get the top element.
     */
    public int top() {
        return this.ll.getLast();
    }

    /**
     * Returns whether the stack is empty.
     */
    public boolean empty() {
        return ll.isEmpty();
    }
}

/**
 * Your MyStack object will be instantiated and called as such:
 * MyStack obj = new MyStack();
 * obj.push(x);
 * int param_2 = obj.pop();
 * int param_3 = obj.top();
 * boolean param_4 = obj.empty();
 */